#ifndef _PVU_UI_SELECTION_H_
#define _PVU_UI_SELECTION_H_

#include "ui/ui_widget.h"

namespace editor
{
class EditorMain;
class EditorBrush;

class UISelection
{
public:
	UISelection(EditorBrush*	pBrush, const std::string& Name) : m_pBrush(pBrush), m_Name(Name), m_pPanel(0), m_RenderName(!Name.empty()), m_Offset(0), m_ToClose(false) {};
	virtual ~UISelection() {Hide(); };
	virtual void				Show(bool	RenderName) = 0;
	virtual void				Reset() = 0;
	virtual void				Tick(float dt) = 0;

	virtual void				Scroll(int Dir) = 0;
	bool						IsVisible() 
	{ 
		return m_pPanel && m_pPanel->IsVisible(); 
	};
	void						ToggleVisible()
	{
		if (!m_pPanel) return;
		m_pPanel->SetIsVisible(!m_pPanel->GetIsVisible());
	}
	virtual void				Hide() 
	{
		if (!m_pPanel) return;
		m_pPanel->SetIsVisible(false);
	}
protected:
	EditorBrush*				m_pBrush;
	ui::UIWidget*				m_pPanel;
	bool						m_RenderName;
	std::string					m_Name;
	int							m_Offset;
	bool						m_ToClose;
};	

class	TextSelect : public UISelection
{
public:
	TextSelect(EditorBrush*	pBrush, const std::string& Name);
	~TextSelect();

	void				Show(bool	RenderName);
	void				Reset();
	void				UpdateEntries();
	void				Tick(float dt);

	void				FromList(const std::vector<std::string>& List);
	void				FromDirectory(const std::string& Dir, bool TruncateName = true);

	void				Scroll(int Dir);

	void DELEGATE_CALL	OnScrollUp(ui::UIWidget::WIDGET_EVENT Event, ui::UIWidget* pWidget) { Scroll(-1); }
	void DELEGATE_CALL	OnScrollDown(ui::UIWidget::WIDGET_EVENT Event, ui::UIWidget* pWidget) { Scroll(1); }
	void DELEGATE_CALL	OnElementSelected(ui::UIWidget::WIDGET_EVENT Event, ui::UIWidget* pWidget);
	void DELEGATE_CALL	OnHide(ui::UIWidget::WIDGET_EVENT Event, ui::UIWidget* pWidget);
protected:
	std::vector<std::string>	m_Entries;
	static const int			WIDGET_C = 19;
	ui::UIWidget*				m_WidgetA[WIDGET_C];

};
} // namespace editor
#endif // _PVU_UI_SELECTION_H_